#include "UserComand.h"

#include "TECommonFunctions.h"
#include "UserCommandEnum.h"
#include "WordList.h"
#include "CurrentTime.h"
#include <vector>
#include <iostream>
#include "EventTime.h"

using namespace std;
using namespace CommonDataType;
using namespace StringManipulator;
using namespace UCTimeHandler;
using TimeManipulator::TimeType;

void outList (AWord* ptr);
string outNature(Nature input) {
	switch (input)
	{
	case Nature::UNDEFINED:
		return "undefined";
		break;
	case Nature::DYING:
		return "dying";
		break;
	case Nature::USELESS:
		return "useless";
		break;
	case Nature::TODAY:
		return "today";
		break;
	case Nature::TOMORROW:
		return "tomorrow";
		break;
	case Nature::MORNING:
		return "morning";
		break;
	case Nature::AFTERNOON:
		return "afternoon";
		break;
	case Nature::PREP:
		return "preposition";
		break;
	case Nature::OCLOCK:
		return "o'clock";
		break;
	case Nature::NUMBER:
		return "number";
		break;
	case Nature::MONTHS:
		return "months";
		break;
	case Nature::WEEKDAY:
		return "day_of_week;";
		break;
	case Nature::AMPM:
		return "am_pm";
		break;
	case Nature::DATE:
		return "date";
		break;
	case Nature::TIME:
		return "time";
		break;
	case Nature::WORD_TO:
		return "word_to";
		break;
	case Nature::DURATION_CHAR:
		return "duration character";
		break;
	default:
		return "error";
		break;
	}
}

string outBool(bool input) {
	if (input) return "true";
	else return "false";
}
void main()
{
	pos_int rubbish;
	con_chr charList[] = {'-', '.' ,'/'};
	
	WriteSettingPtr config = &Settings::get();
	config->setDateDisplayFormat(DateDisplayFormat::DDMMYY);
	config->setTimeDisplayFormat (TimeDisplayFormat::TWENTY_FOUR);
	/*string str1 = "Watch the horror movie \'ghost may cry\' on 21-3-2012 before 9 at night.";
	string str2 = "meet Calvin  at NUS on Monday which is 3 Jan before \n11:00p.m., have to be there before 6 oclock in the evening\nI'll need to prepare some work by tmr ";
	string str3 = "meet Calvin at NUS on 21/9/14, better be there before 4 in the afternoon";
	string str4 = "meet Calvin at NUS on 99.99.999 or 2014/100/2 before 25:00 at central library -_-";
	string str5 = "meet Calvin on 2014.1.4";*/

	/*cout << "The input string is: \n\"" << str1 << "\"" << endl;
	WordList testList (str1);
	cout << "Chop the sentence into pieces, analysing...\n" << endl;
	for (pos_int i = 0; i < testList.getSize(); i++) {
		cout << "The word is: \"" << testList[i].getWord() << "\" Index is: " << testList[i].getIndex() <<
			". Its nature is: " << outNature (testList[i].getNature()) <<endl;
	}*/

	/*string  p1,p2;
	testList.solveAll();
	p1 =testList.getTimeString();
	p2 =testList.getDateString();
	
	if (p1 != NULL_STRING) {
		cout << "Time string is: " << p1 << endl;
	}
	else {
		cout << "Time string not found" << endl;
	}

	if (p2 != NULL_STRING) {
		cout << "Date string is: " << p2 <<endl;
	}
	else {
		cout << "Date string not found" << endl;
	}*/
	string str1 = NULL_STRING;
/*	while (true) {
		getline (cin, str1);
		WordList testList(str1);
		testList.solveAll();
		AWord* ptr = testList.getHead();
		outList (ptr);
		string(*strp)[2];
		strp = (string(*)[2]) testList.getTimeString();
		cout << "Is it a time duration? " << outBool (
			testList.isTimeStringDuration()
			) << endl;
		cout << "Start from "<< (*strp)[0] << endl;
		cout << "Ends at " << (*strp)[1] << endl;
		strp = (string(*)[2]) testList.getDateString();
		cout << "Is it a date duration? " << outBool (
			testList.isDateStringDuration()
			) << endl;
		cout << "Start from "<< (*strp)[0] << endl;
		cout << "Ends at " << (*strp)[1] << endl;
	}*/
	while (true) {
		getline (cin, str1);
		UserCommand haha;
		haha.analyse (str1);
	}
}

void outList (AWord* ptr) {
	AWord* temp = ptr;
	while (temp->getType() != NodeType::TAIL) {
		cout << "The word is \"" << temp->getWord();
		cout <<"\". Its nature is " << outNature (temp->getNature());
		cout << endl;
		temp = temp->getNext();
	}
	cout << "The word is \"" << temp->getWord();
	cout <<"\". Its nature is " << outNature (temp->getNature());
	cout << endl;
	temp = temp->getNext();
}
